﻿/*
 * NetTcpConnection.h
 *
 */
#ifndef __GDK_NETTCPCONNECTION_H__
#define __GDK_NETTCPCONNECTION_H__

#include <gdk/net/Socket.h>
#include <gdk/net/TcpStream.h>
#include <gdk/net/NetEvent.h>
#include <gdk/net/NetConnection.h>


namespace gdk
{

	class GDK_NET_EXPORT NetTcpConnection : public TcpStream, public NetConnection
	{
		DECLARE_CLASS_HANDLE(NetTcpConnection)
		DECLARE_CLASS_INSTANCE(NetTcpConnection)

	private:
		bool	_error;
		bool	_connected;

	private:
		NetTcpConnection(void);
		~NetTcpConnection(void);

	public:
		virtual void onTick(uint32_t timeSinceLastTick);
		virtual bool attach(SOCKET hSocket);
		virtual void close(void);
		virtual void exit(void);
		//--------------------------------------------

	public:
		__INLINE__ bool isConnected(void) const { return (getConnectionState() == CONNECTED); } //检查网络是否连接
		//--------------------------------------------
	};
	typedef NetTcpConnection::Handle	NetTcpConnectionPtr;


} //namespace gdk


#endif //__GDK_NETTCPCONNECTION_H__
